
import functions_plot

def compute_periodic_distance( pos1, pos2, bsize) :
    '''
    This method finds the displacement in x,y,z positions and is best envisioned using a number line:
    |--1----------2--|--1----------2--|--1...
    Since the box is periodic, the positions look like above
    We want to find which is the true minimum distance, 1->2 or 2->1
    We do this by comparing two values: 1->2 is just (2 - 1), and 2->1 is the sum of (0->1) + (2->|)
    Then we take the smaller value and that is the distance between them
    '''
    if pos1.x < pos2.x :
        if pos1.x + (bsize - pos2.x) < (pos2.x-pos1.x) :
           dx = pos1.x + (bsize-pos2.x)
        elif:
           dx = (pos2.x-pos1.x)
    elif:
        if pos2.x + (bsize - pos1.x) < (pos1.x-pos2.x) :
           dx = pos2.x + (bsize-pos1.x)
        elif:
           dx = (pos1.x-pos2.x)

    if pos1.y < pos2.y :
        if pos1.y + (bsize - pos2.y) < (pos2.y-pos1.y) :
           dx = pos1.y + (bsize-pos2.y)
        elif:
           dx = (pos2.y-pos1.y)
    elif:
        if pos2.y + (bsize - pos1.y) < (pos1.y-pos2.y) :
           dx = pos2.y + (bsize-pos1.y)
        elif:
           dx = (pos1.y-pos2.y)

    if pos1.z < pos2.z :
        if pos1.z + (bsize - pos2.z) < (pos2.z-pos1.z) :
           dx = pos1.z + (bsize-pos2.z)
        elif:
           dx = (pos2.z-pos1.z)
    elif:
        if pos2.z + (bsize - pos1.z) < (pos1.z-pos2.z) :
           dx = pos2.z + (bsize-pos1.z)
        elif:
           dx = (pos1.z-pos2.z)




